package com.hongmeng.teamwork.factory.task;

import com.google.common.collect.Lists;
import com.hongmeng.teamwork.entity.dto.TaskMessageDto;
import com.hongmeng.teamwork.entity.dto.TeamworkTaskDto;
import com.hongmeng.teamwork.enums.TaskOptTypeEnum;
import com.hongmeng.teamwork.enums.TaskStatusEnum;
import com.hongmeng.teamwork.tempalte.MessageSendTemplate;
import org.springframework.stereotype.Service;

/**
 * 任务新增策略类
 */
@Service
public class TaskCreateHandler implements TaskOptHandler{

    @Override
    public TaskOptTypeEnum getOptType() {
        return TaskOptTypeEnum.CREATE_TASK;
    }

    @Override
    public String buildMessage(TaskMessageDto taskMessageDto) {
        TeamworkTaskDto teamworkTaskDto = taskMessageDto.getTeamworkTaskDto();
        return  MessageSendTemplate.createTaskTemplate(teamworkTaskDto.getCreatedUser().getName(),
                teamworkTaskDto.getName(),
                taskMessageDto.getProjectName(),
                teamworkTaskDto.getLeadUser().getName(),
                teamworkTaskDto.getDescription(),
                Lists.newArrayList(teamworkTaskDto.getStartTime()),
                Lists.newArrayList(teamworkTaskDto.getEndTime()),
                TaskStatusEnum.ofEnum(teamworkTaskDto.getStatus())
        );
    }
}
